#ifndef PLOT_H
#define PLOT_H

#include <gnuplot_i.h>
#include <plib.h>

#define YES 1
#define NO 0
#define MAX_WINS 10

/* output options */
#define STDOUT 1
#define PNG 2
#define PS 3
#define EPS 4
#define PDF 5
#define FILES 6

/* plot options */
#define NO_BORDER 0
#define BORDER 1
#define NO_GRID 0
#define GRID 1
#define NO_KEY 0
#define KEY 1
#define NO_XTICS 0
#define XTICS 1
#define NO_YTICS 0
#define YTICS 1

/* plot style */
#define PLOT_DEFAULT 0
#define PLOT_POINTS 1
#define PLOT_HISTEPS 2
#define PLOT_BOXES 3
#define PLOT_LINES 4
#define PLOT_LINESPOINTS 5

typedef struct ctrl{
  int multiple_win;
  int plot_out;
  int stat_out;
  char *plot_file;
  char *stat_file;
}ctrl;

typedef struct data{
  double* pdata; /* for mem allocation */

  int nb;
  double *x;
  double *y;
  double *z;
  char *title;
  int style;
}data;

typedef struct plot{
  char *xlabel;
  char *ylabel;
  char *zlabel;
  char *title;
  int border;
  int grid;
  int key;
  int xtics;
  int ytics;
  double startx; /*no used */
  double endx; /*not used */
  double starty; /*not used*/
  double endy; /*not used*/
  int nbdat;
  data *dat;
  gnuplot_ctrl *win;
  int w;
  int max_w;
  gnuplot_ctrl **wins;
}plot;

plot *PLOT_xy(double** x,double** y, char** fields, int* id_fields, int nb, char *xlabel,char *ylabel,char *title,int border,int grid,int key,int xtics,int ytics);
plot *PLOT_getDistribution(double **data,int nb_bars,char **fields,int* id_fields,int nb_fields,char *xlabel,char *ylabel,char *title,int border,int grid,int key,int xtics,int ytics);

int PLOT_draw(plot* plot,ctrl *ctrl,char **names);
int PLOT_close(plot* plot,ctrl *ctrl);
void PLOT_free(plot* plot, ctrl* ctrl);
#endif
